import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;

public class Card {
	final public static int width = 71;
	final public static int height = 96;
	final public static int spade = 0;
	final public static int heart = 1;
	final public static int club = 2;
	final public static int diamond = 3;

	private boolean faceup;
	private int rank;
	private int suit;

	public Card(int suit, int rank) {
		this.suit = suit;
		this.rank = rank;
	}

	public int getRank() {
		return rank;
	}

	public int getSuit() {
		return suit;
	}

	public boolean isFaceup() {
		return faceup;
	}

	public final void flip() {
		faceup = !faceup;
	}

	public final Color color() {
		if (isFaceup()) {
			if (getSuit() == heart || getSuit() == diamond)
				return Color.red;
			else
				return Color.black;
		}
		return Color.yellow;
	}

	public void draw(Component c, Graphics g, int x, int y) {
		Image i;
		if (isFaceup()) {
			i = Toolkit.getDefaultToolkit().getImage(
					"images/" + (getSuit()+1) + "-" + (getRank()+1) + ".gif");
		} else {
			i = Toolkit.getDefaultToolkit().getImage(
					"images/rear.gif");
		}
		g.drawImage(i, x, y, width, height, c);

	}

}
